from selenium.webdriver.common.by import By

from Page.base_page import BuyerBasePage
import logging


class IndexPage(BuyerBasePage):
    def __init__(self):
        super().__init__()

        self.my_oder = (By.XPATH, "//a[contains(text(),'我的订单')]")
        self.my_visit = (By.XPATH, "//a[contains(text(),'我的浏览')]")
        self.my_collector = (By.XPATH, "//a[contains(text(),'我的收藏')]")
        self.my_cart = (By.XPATH, "//span[contains(text(),'我的购物车')]")
        # 搜索输入框
        self.search_box = (By.CLASS_NAME, 'ecsc-search-input')
        # 搜索按钮
        self.search_bth =(By.CLASS_NAME, 'ecsc-search-button')

    # 进入我的订单
    def get_my_order(self):
        self.find_el(*self.my_oder).click()

    # 进入我的浏览
    def get_my_visit(self):
        self.find_el(*self.my_visit).click()

    # 进入我的收藏
    def get_my_collector(self):
        self.find_el(*self.my_collector).click()

    # 进入我的购物车
    def get_my_car(self):
        self.find_el(*self.my_cart).click()

    # 搜索商品
    def search(self, goods):
        self.input_text(self.find_el(*self.search_box), goods)
        self.find_el(*self.search_bth).click()
